import fetch from '@/utils/fetch'

var qs = require('qs')

// 查询权限名称 By 权限名称:name
export function GetPersimmonName(inputName) {
  console.log('inputName',inputName)
  return fetch({
    url: '/permission/getByName',
    method: 'get',
    params: { inputName }
  })
}

// 查询查询权限名称 分页
export function GetPersimmonPage(page, seachName) {
  return fetch({
    url: '/permission/getByPage',
    method: 'post',
    data: qs.stringify({ ...page, seachName })
      // {'page': page, 'sysPersimmon': sysPersimmon}//qs.stringify({page: page, sysPersimmon: 'sysPersimmon'})

  })
}

export function GetParentPermission(pids) {
  return fetch({
    url: '/permission/getParentPermission',
    method: 'post',
    data: JSON.stringify(pids),
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }

  })
}

export function GetPermissionLikeName(name) {
  return fetch({
    url: '/permission/getPermissionLikeName',
    method: 'get',
    params: { name }
  })
}

export function SavePermission(permission) {
  return fetch({
    url: '/permission/savePermission',
    method: 'post',
    data: JSON.stringify(permission),
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }
  })
}

export function DelPermission(id) {
  return fetch({
    url: '/permission/delPermission',
    method: 'get',
    params: { id }
  })
}

export function GetExcle() {
  return fetch({
    url:'/permission/getExcle',
    method:"post",
    responseType: 'blob'
  })
}

export function GetPermissionTree() {
  return fetch({
    url:'/permission/getPermissionTree',
    method:'get'
  })
}

export function GetPermissionTreeByPermissionIds(permissionIds) {
  return fetch({
    url: '/permission/getPermissionTreeByPermissionIds',
    method: 'post',
    data: JSON.stringify(permissionIds),
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }
  })
}
